<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>material</title>
    <script src="__LAYUI__/layui.js"></script>
    <link href="__LAYUI__/css/layui.css" rel="stylesheet"/>
</head>
<body>
<script src="__LAYUI__/layui.js"></script>
<link href="__LAYUI__/css/layui.css" rel="stylesheet"/>

<table id="table" lay-filter="test"></table>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
</script>



<script>
    layui.use(['table','jquery','layer'], function () {
        var table = layui.table,
            $ = layui.$;
        table.render({
            elem: '#table'
            ,
            id: 'idTest'
            ,
            height: 370
            ,
            skin: 'line'
            ,
            even: true
            ,
            size: 'lg'
            ,
            cols: [[
                {field: 'company_id', title: 'ID', width: 50}
                , {field: 'company_name', title: '出版社名称', width: 200}
                , {field: 'company_url', title: '出版社网址', width: 300}
                , {field: 'company_logo', title: '出版社图片url', width: 400}
                , {fixed: 'right', width: 160, align: 'center', toolbar: '#barDemo'}
            ]]

            ,response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                ,statusCode: 1 //成功的状态码，默认：0
            }
            ,url:'/index/Company/getCompany'
        });

        table.on('tool(test)',function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            var tr = obj.tr;

            if(layEvent === 'edit'){
                layer.open({
                    type: 2,
                    offset:'0px',
                    title: '出版社修改' ,
                    scrollbar: false,
                    resize: false,
                    area:['600px','570px'],
                    shadeClose: true,
                    content: ['/index/Adm/changeCompany?company_id='+data.company_id,'no'],
                });
            }
        });
    });
</script>

</body>
</html>